<template>
  <div class="total">
    <div class="title">
      <h1>送货到家</h1>
      <div class="content-title">
        <h2>客户信息：</h2>
        <h2>送货信息：</h2>
      </div>
    </div>
    <div class="custom-information">
      <div class="left-information">
        <table>
          <tr>
            <td>收货人</td>
            <td>蔡公子</td>
            <td>联系方式</td>
            <td>13598456991</td>
          </tr>
          <tr>
            <td>收货地址</td>
            <td>
              蔡徐坤工作室地址:上海市松江区北松公路4915号16幢(上海影视乐园内)。
            </td>
            <td>购买时间</td>
            <td>2022.10.19</td>
          </tr>
          <tr>
            <td>备注</td>
            <td>别要签名不要大呼小叫 谢谢合作</td>
            <td>产品</td>
            <td>双开门马桶</td>
          </tr>
        </table>
      </div>
      <div class="right-information">
        <table>
          <tr>
            <td>送货人</td>
            <td>陈运通</td>
            <td>联系方式</td>
            <td>1381381438</td>
          </tr>
          <tr>
            <td>送货时间</td>
            <td>2022.10.20</td>
            <td>送货状态</td>
            <td>未送达</td>
          </tr>
        </table>
      </div>
    </div>
  </div>
  <div class="sousuo">
    <div class="sousuo1">
      <p>商品名称:</p>
      <el-input v-model="search" size="large" placeholder="Type to search" />
    </div>
    <div class="sousuo2">
      <p>联系人员:</p>
      <el-input v-model="search1" size="large" placeholder="Type to search" />
    </div>
    <div class="sousuo3">
      <p>状态：</p>
      <el-input v-model="search1" size="large" placeholder="已派遣" />
    </div>
  </div>
  <el-table :data="custom" style="width: 100%" :cell-style="cellStyle">
    <el-table-column fixed prop="cShorts" label="商品名称" width="200" />
    <el-table-column prop="cName" label="联系人员" width="200" />
    <el-table-column prop="cPhone" label="联系方式" width="200" />
    <el-table-column prop="addr" label="人员地址" width="200" />
    <el-table-column prop="cNow" label="状态" width="200" />
    <el-table-column prop="cData" label="时间" width="200" />
    <el-table-column label="操作" prop="cmake" width="200">
      <template #default="scope">
        <el-button link type="primary" text @click="openVn(scope.row)">
          派遣</el-button
        >
      </template>
    </el-table-column>
  </el-table>
  <div>
    <el-dialog v-model="dialogTableVisible" title="派遣人员">
      <el-table
        ref="multipleTableRef"
        :data="gridData"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column prop="goodsName" label="姓名" width="200">
        </el-table-column>
        <el-table-column prop="goodsPhone" label="联系方式" width="200" />
        <el-table-column
          prop="goodsStatus"
          label="工作状态"
          show-overflow-tooltip
        />
        <el-table-column align="right">
          <template #default="scope">
            <el-button size="small">确认派遣</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script lang="ts" setup>
import {
  ref,
  onMounted,
  onBeforeUnmount,
  computed,
  watch,
  nextTick,
  h,
} from "vue";
import dayjs from "dayjs";
import { indexApi } from "@/api/api";
import "@/mock/index";
import { useStore } from "vuex";
import { ElMessage } from "element-plus";
const store = useStore();
interface User {
  cNow: string;
  row: any;
  rowIndex: string;
  column: any;
  columnIndex: number;
}
const search = ref<string>("");
const search1 = ref<string>("");

let custom = ref<User>();
let cellStyle = ({ row, rowIndex, column, columnIndex }: User) => {
  let cellstyle: any;
  if (column.label == "状态" && columnIndex == 4 && row.cNow == "未派遣") {
    return { color: "red" };
  }
  if (column.label == "状态" && columnIndex == 4 && row.cNow == "已派遣") {
    // dialogTableVisible.value = false;
    return { color: "green" };
  }
};
// 派遣人员
let gridData = ref<any>([
  {
    date: "2016-05-03",
    name: "John Smith",
    address: "No.1518,  Jinshajiang Road, Putuo District",
  },
]);
onMounted(async () => {
  store.dispatch("getCustom").then((res) => {
    custom.value = res.data;
  });
  // 派遣人员
  const list = await indexApi({ data: "data" });
  console.log(list.data);
  gridData.value = list.data;
});
let dialogTableVisible = ref<boolean>(false);
// 多选
const multipleSelection = ref<User[]>([]);
const handleSelectionChange = (val: User[]) => {
  multipleSelection.value = val;
};
// 是否派遣
const openVn = (row: any) => {
  if (row.cNow == "未派遣") {
    dialogTableVisible.value = true;
  } else {
    dialogTableVisible.value = false;
  }
  if (row.cNow == "已派遣") {
    ElMessage({
      message: h("p", null, [
        h("span", null, "已派遣 "),
        h("i", { style: "color: teal font-size:24px" }),
      ]),
    });
  }
};
</script>

<style lang="less" scoped>
.total {
  margin: 10px 0px 0px 10px;

  .title {
    background-color: #cfe6ff;
    display: flex;
    flex-direction: column;

    h1 {
      font-size: 16px;
      font-family: Adobe Heiti Std;
      font-weight: normal;
      color: #020202;
      line-height: 40px;
      margin-left: 10px;
    }

    .content-title {
      display: flex;

      h2 {
        flex: 1;
        font-size: 12px;
        font-family: Adobe Heiti Std;
        font-weight: normal;
        color: #020202;
        margin: 0px 0px 10px 10px;
      }
    }
  }

  .custom-information {
    display: flex;
    background-color: #cfe6ff;

    .left-information {
      height: 150px;
      flex: 1;
      // border: 1px solid #000000;
      background-color: #5be0e8;

      table {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-evenly;

        tr {
          display: flex;

          td {
            border: 1px solid #fefefe;
            flex: 1;
            text-align: center;
            line-height: 47px;
            font-size: 12px;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            color: #020202;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
        }
      }
    }

    .right-information {
      height: 150px;
      flex: 1;
      // border: 1px solid #000000;
      margin-left: 10px;
      background-color: #5be0e8;

      table {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-evenly;

        tr {
          display: flex;

          td {
            border: 1px solid #fefefe;
            flex: 1;
            text-align: center;
            line-height: 72px;
            font-size: 12px;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            color: #020202;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
        }
      }
    }
  }
}

.sousuo {
  display: flex;
  margin-bottom: 4px;
  margin-top: 10px;

  .sousuo1 {
    display: flex;

    p {
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 16px;
      width: 120px;
    }

    margin-right: 60px;
  }

  .sousuo2 {
    display: flex;

    p {
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 16px;
      width: 120px;
    }
  }

  .sousuo3 {
    display: flex;

    p {
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 16px;
      width: 120px;
    }
  }
}

.el-input__inner {
  margin-bottom: 20px;
}
</style>
